package com.juzi.type;

public class TypeDemo1 {
    public static void main(String[] args) {
        //目标：理解自动类型转换
        System.out.println("目标：理解自动类型转换\n" +
                "===================================\n\n"+
                "什么是自动类型转换，为什么要学习自动类型转换？\n" +
                "类型范围小的变量，可以直接赋值给类型范围大的变量。\n" +
                "-------------------------------\n" +
                "自动类型转换的底层原理\n" +
                "byte a = 12;         a   00001100    (8位)             \n" +
                "int b = a;           b   00000000 00000000 00000000 00001100  (32位)\n" +
                "System.out.println(b); // 12\n" +
                "-------------------------------\n" +
                "自动类型转换的其他形式\n" +
                "byte --→ short --→ int --→ long --→ float --→ double\n" +
                "                    ↑\n" +
                "                   char\n");
        byte a = 20;
        int b = a;//发生了自动类型转换
        System.out.println(a);
        System.out.println(b);

        int age = 23;
        double db = age;//自动类型转换
        System.out.println(db);
        System.out.println(age);

        char ch = 'a';//00000000 01100001
        int code = ch;//00000000 00000000 00000000 01100001
        System.out.println(code);
    }
}
